<?php

namespace App\Livewire\Components;

use App\Models\Message;
use Livewire\Component;

class MessageSpeak extends Component
{

    public $email = '';

    public $content = '';

    public function speak()
    {
        Message::create([
            'name'    => '匿名用户',
            'email'   => $this->email,
            'content' => $this->content,
            'ip'      => request()->getClientIp(),
        ]);
        $this->js("alert('感谢您的评论，请耐心等待审核!')");
        $this->redirect('/message');
    }


    public function render()
    {
        return view('livewire.components.message-speak');
    }
}
